const sessionStorage = window.sessionStorage;

export class Auth {
  static getUserInfo() {
    const user = JSON.parse(localStorage.getItem('UserInfo'))
    return user ? JSON.parse(localStorage.getItem('UserInfo')) : {}
  }

  static setUser(value) {
    return sessionStorage.setItem('user', JSON.stringify(value))
  }

  static removeUser() {
    return sessionStorage.removeItem('user')
  }
  static getCourse() {
    const course = {

    }

    return course ? JSON.parse(sessionStorage.getItem('course')) : {}
  }

  static setCourse(value) {
    return sessionStorage.setItem('course', JSON.stringify(value))
  }

  static removeCourse() {
    return sessionStorage.removeItem('course')
  }

  static getWorkId() {
    const workId = sessionStorage.getItem('workId')
    return workId ? JSON.parse(sessionStorage.getItem('workId')) : {}
  }

  static setWorkId(value) {
    return sessionStorage.setItem('workId', JSON.stringify(value))
  }

  static removeWorkId() {
    return sessionStorage.removeItem('workId')
  }
  // 存储某一个课程
  static getCourseId() {
    const courseId = sessionStorage.getItem('courseId')
    return courseId ? JSON.parse(sessionStorage.getItem('courseId')) : {}
  }

  static setCourseId(value) {
    return sessionStorage.setItem('courseId', JSON.stringify(value))
  }

  static removeCourseId() {
    return sessionStorage.removeItem('courseId')
  }
}

